using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pokemon
{
    public class Lane
    {
        private List<Blank> _blanks;
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="blanks"></param>
        public Lane(List<Blank> blanks)
        {
            _blanks = blanks;
        }

        /// <summary>
        /// 
        /// </summary>
        public int Size
        {
            get { return _blanks.Count; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="unit"></param>
        /// <param name="i"></param>
        /// <returns></returns>
        public Zombie GetEnemy(Pokemon unit, int i)
        {

            for (int j = i; j < Size; j++)
            {
                Zombie z = _blanks[j].GetZombieNearest(unit.GetCenterPoint());
                if (z != null)
                    return z;
            }
            return null;
        }


        public Pokemon GetEnemy(Zombie unit, int i)
        {            
            for (var j = i; j >= 0; j--)
            {
                Pokemon p = _blanks[j].Pokemon;
                if (p != null)
                {
                    if (unit.GetCenterPoint().X > p.GetCenterPoint().X)
                        return p;
                }
                    
            }
            return null;
        }

        public Blank GetFirstBlank()
        {
            return _blanks[0];
        }

        public Blank GetLastBlank()
        {
            return _blanks[Size - 1];
        }
    }
}
